package com.umbacos.udm.client.arch;

import com.google.gwt.event.dom.client.MouseDownEvent;
import com.google.gwt.event.dom.client.MouseDownHandler;
import com.google.gwt.event.dom.client.MouseOutEvent;
import com.google.gwt.event.dom.client.MouseOutHandler;
import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.event.dom.client.MouseOverHandler;
import com.google.gwt.event.dom.client.MouseUpEvent;
import com.google.gwt.event.dom.client.MouseUpHandler;
import com.google.gwt.user.client.ui.Image;

public class ImageButton extends Image implements MouseOverHandler, MouseOutHandler, MouseDownHandler, MouseUpHandler {

    private Animator animator = new Animator();
    private int mills;
    private int widthSmall;
    private int widthBig;
    
    public ImageButton(String url, int mills, int widthSmall, int widthBig){
    	super(url);
    	this.mills=mills;
    	this.widthBig=widthBig;
    	this.widthSmall=widthSmall;
    	setSize(widthSmall + "px", widthSmall + "px");
    	setStyleName("pointer");
    	addMouseOverHandler(this);
    	addMouseOutHandler(this);
    	addMouseDownHandler(this);
    	addMouseUpHandler(this);
		addStyleName("pointer");
    }

	@Override
	public void onMouseOver(MouseOverEvent event) {
		animator.addAnimation(new ResizeAnimation(this, mills, widthBig, widthBig));						
	}

	@Override
	public void onMouseOut(MouseOutEvent event) {
		animator.addAnimation(new ResizeAnimation(this, mills, widthSmall, widthSmall));						
	}

	@Override
	public void onMouseDown(MouseDownEvent event) {
		setSize(widthBig-2+"px", widthBig-2+"px");
	}

	@Override
	public void onMouseUp(MouseUpEvent event) {
		animator.addAnimation(new ResizeAnimation(this, mills, widthSmall, widthSmall));						
	}
}
